﻿var manset_degisme_suresi = 4000;
var secili_manset = 1;
var mansetTimeout = 1;
var manset_sayisi_saklambac = 4;
var secili_manset_saklambac = 1;
var mansetTimeout_saklambac = 1;
var manset_sayisi_galeri = 4;
var secili_manset_galeri = 1;
var mansetTimeout_galeri = 1;

function manset_goster() {
    if (typeof manset_sayisi == 'undefined') return;
    for (i = 1; i <= manset_sayisi; i++) {
        if (i == secili_manset) {

            if (!navigator.userAgent.match(/(iPhone|iPod|iPad)/)) {
                $("#tk_mn_div_" + i).find("img").imageload();
            }
            else {
                var img = $("#tk_mn_div_" + i).find("img");
                if (($(img).attr("original") != undefined) && ($(img).attr("src") != $(img).attr("original")))
                    $(img).attr("src", $(img).attr("original")).fadeIn();
            }

            if ((i + 1) < manset_sayisi) {
                if (!navigator.userAgent.match(/(iPhone|iPod|iPad)/)) {
                    $("#tk_mn_div_" + (i + 1)).find("img").imageload();
                }
                else {
                    var img = $("#tk_mn_div_" + (i + 1)).find("img");
                    if (($(img).attr("original") != undefined) && ($(img).attr("src") != $(img).attr("original")))
                        $(img).attr("src", $(img).attr("original")).fadeIn();
                }
            }

            $("#tk_mn_lnk_" + i).addClass("current");
            $("#tk_mn_div_" + i).attr("style", "display:block;");
        }
        else {
            $("#tk_mn_lnk_" + i).removeClass("current");
            $("#tk_mn_div_" + i).attr("style", "display:none;");
        } //if
    } //for
} //function
function manset_degistir(id) {
    if (id >= 1) {
        clearTimeout(mansetTimeout);
        secili_manset = id;
        manset_goster();
    }
    else {
        manset_goster();
        secili_manset = secili_manset + 1;
        if (secili_manset > manset_sayisi) secili_manset = 1;

        mansetTimeout = setTimeout("manset_degistir(-1)", manset_degisme_suresi);
    } //if
} //function


function manset_goster_saklambac() {
    if (typeof manset_sayisi_saklambac == 'undefined') return;
    for (i = 1; i <= manset_sayisi_saklambac; i++) {
        if (i == secili_manset_saklambac) {

            if (!navigator.userAgent.match(/(iPhone|iPod|iPad)/)) {
                $("#tk_sklmbc_div_" + i).find("img").imageload();
            }
            else {
                var img = $("#tk_sklmbc_div_" + i).find("img");
                if (($(img).attr("original") != undefined) && ($(img).attr("src") != $(img).attr("original")))
                    $(img).attr("src", $(img).attr("original")).fadeIn();
            }

            if ((i + 1) < manset_sayisi_saklambac) {
                if (!navigator.userAgent.match(/(iPhone|iPod|iPad)/)) {
                    $("#tk_sklmbc_div_" + (i + 1)).find("img").imageload();
                }
                else {
                    var img = $("#tk_sklmbc_div_" + (i + 1)).find("img");
                    if (($(img).attr("original") != undefined) && ($(img).attr("src") != $(img).attr("original")))
                        $(img).attr("src", $(img).attr("original")).fadeIn();
                }
            }

            $("#tk_sklmbc_lnk_" + i).addClass("current");
            $("#tk_sklmbc_div_" + i).attr("style", "display:block;");
        }
        else {
            $("#tk_sklmbc_lnk_" + i).removeClass("current");
            $("#tk_sklmbc_div_" + i).attr("style", "display:none;");
        } //if
    } //for
} //function
function manset_degistir_saklambac(id) {
    if (id >= 1) {
        clearTimeout(mansetTimeout_saklambac);
        secili_manset_saklambac = id;
        manset_goster_saklambac();
    }
    else {
        manset_goster_saklambac();
        secili_manset_saklambac = secili_manset_saklambac + 1;
        if (secili_manset_saklambac > manset_sayisi_saklambac) secili_manset_saklambac = 1;

        mansetTimeout_saklambac = setTimeout("manset_degistir_saklambac(-1)", manset_degisme_suresi);
    } //if
} //function

function manset_goster_galeri() {
    if (typeof manset_sayisi_galeri == 'undefined') return;
    for (i = 1; i <= manset_sayisi_galeri; i++) {
        if (i == secili_manset_galeri) {

            if (!navigator.userAgent.match(/(iPhone|iPod|iPad)/)) {
                $("#tk_galeri_div_" + i).find("img").imageload();
            }
            else {
                var img = $("#tk_galeri_div_" + i).find("img");
                if (($(img).attr("original") != undefined) && ($(img).attr("src") != $(img).attr("original")))
                    $(img).attr("src", $(img).attr("original")).fadeIn();
            }

            if ((i + 1) < manset_sayisi_galeri) {
                if (!navigator.userAgent.match(/(iPhone|iPod|iPad)/)) {
                    $("#tk_galeri_div_" + (i + 1)).find("img").imageload();
                }
                else {
                    var img = $("#tk_galeri_div_" + (i + 1)).find("img");
                    if (($(img).attr("original") != undefined) && ($(img).attr("src") != $(img).attr("original")))
                        $(img).attr("src", $(img).attr("original")).fadeIn();
                }
            }

            $("#tk_galeri_lnk_" + i).addClass("current");
            $("#tk_galeri_div_" + i).attr("style", "display:block;");
        }
        else {
            $("#tk_galeri_lnk_" + i).removeClass("current");
            $("#tk_galeri_div_" + i).attr("style", "display:none;");
        } //if
    } //for
} //function
function manset_degistir_galeri(id) {
    if (id >= 1) {
        clearTimeout(mansetTimeout_galeri);
        secili_manset_galeri = id;
        manset_goster_galeri();
    }
    else {
        manset_goster_galeri();
        secili_manset_galeri = secili_manset_galeri + 1;
        if (secili_manset_galeri > manset_sayisi_galeri) secili_manset_galeri = 1;

        mansetTimeout_galeri = setTimeout("manset_degistir_galeri(-1)", manset_degisme_suresi);
    } //if
} //function

$(function () {
    //Default Action
    if (typeof manset_sayisi != 'undefined')
        mansetTimeout = setTimeout("manset_degistir(-1)", manset_degisme_suresi);

    if (typeof manset_sayisi_saklambac != 'undefined')
        mansetTimeout_saklambac = setTimeout("manset_degistir_saklambac(-1)", manset_degisme_suresi);

    if (typeof manset_sayisi_galeri != 'undefined')
        mansetTimeout_galeri = setTimeout("manset_degistir_galeri(-1)", manset_degisme_suresi);

    $("#tk_mn_div_1").find("img").imageload();
    $("#tk_sklmbc_div_1").find("img").imageload();
    $("#tk_galeri_div_1").find("img").imageload();

    if (!navigator.userAgent.match(/(iPhone|iPod|iPad)/)) {
        if ($(".haber img[original]").length > 0)
            $(".haber img[original]").lazyload({
                effect: "fadeIn"
            });
    }
    else {
        $(".haber img[original]").each(function () {
            if (($(this).attr("original") != undefined) && ($(this).attr("src") != $(this).attr("original")))
                $(this).attr("src", $(this).attr("original")).fadeIn();
        });
    }

});

$.fn.imageload = function () {
    if (($(this).attr("original") != undefined) && ($(this).attr("src") != $(this).attr("original")))
        $(this).attr("src", $(this).attr("original")).fadeIn();
}
